<html>
  <body>
    <body>

      <button class="btn1">按钮1</button>

    </body>
  
    <script>
  
  // const elem = document.querySelector(".btn1");


const event = new Event("build");

const elem = new EventTarget();



// 监听该事件。
elem.addEventListener(
  "build",
  (e) => {
    console.log(222)
    /* … */
  },
  false,
);

// 分派该事件。
elem.dispatchEvent(event);

  </script>
</html>